#include "StdAfx.h"
#include "Geometries.h"
#include "Geometry.h"
#include "Utility\ColladaGeometry.h"
#include "Utility\ColladaFile.h"
#include "DxRenderer.h"


Geometries::Geometries(void)
{
}


Geometries::~Geometries(void)
{
}

bool Geometries::Load(const char* pszFile)
{
	bool bRet = false;

	ColladaFile* file = new ColladaFile();
	bRet = file->Load(pszFile);

	if( bRet )
	{
		m_aGeometry.SetSize(file->GeometryCount());

		for(int i = 0; i < m_aGeometry.GetNumElements(); i++)
		{
			ColladaGeometry* colladaGeo = file->Geometry(i);
			Geometry* geometry = new Geometry(colladaGeo);				
			m_aGeometry.Add(geometry);
		}		

	}

	

	delete file;

	return bRet;

}

void Geometries::Draw(const Matrix& mWorld)
{
	DxRenderer* renderer = DxRenderer::GetInstance();
	renderer->SetWorld(mWorld);
	for(int i = 0; i < m_aGeometry.GetNumElementsUsed(); i++)
	{
		renderer->DrawGeometry(m_aGeometry[i], mWorld);
	}

}